import java.util.*;

public class DarrTest {
    static public Scanner sc = new Scanner(System.in);

    static public void main(String [] args) {
        int num;

        Darr darr = new Darr();

        while (true) {
            System.out.printf("请输入整型(-1为退出): ");
            num = sc.nextInt();
            if (num == -1)
                break;
            darr.add(num);
        }


        // 在之打印刚才用户输入的所有数
        for (int i = 0; i < darr.length(); ++i) {
            System.out.printf("%d ", darr.ind(i));
        }
        System.out.println();
        darr.remove(0, 0);
        num = 0;
        while (darr.next()) {
            if (num++ == 5)
                break;
            System.out.printf("%d ", darr.value());
        }
        darr.rewind();
        System.out.println();
        while (darr.next()) {
            System.out.printf("%d ", darr.value());
        }
        System.out.println();
    }
}
